import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:taonile/config/config.dart';
import 'package:taonile/entity/apply_business_info_entity.dart';
import 'package:taonile/routers/routers.dart';

import '../http/api.dart';

///
/// 入驻之前的信息展示
///
class MyStoreToJoinBefore extends StatefulWidget {
  const MyStoreToJoinBefore({Key? key}) : super(key: key);

  @override
  State<MyStoreToJoinBefore> createState() => _MyStoreToJoinBeforeState();
}

class _MyStoreToJoinBeforeState extends State<MyStoreToJoinBefore> {
  ApplyBusinessInfoEntity entity = ApplyBusinessInfoEntity();

  @override
  void initState() {
    super.initState();
    getdatas();
  }

  ////审核状态:waiting=等待审核,pass=通过,failed=未通过,not_applied=未申请
  getdatas() async {
    dynamic result = await Api.businessDetail();
    entity = ApplyBusinessInfoEntity.fromJson(result);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Config.colorBg,
      appBar: AppBar(
        title: const Text('商家入驻'),
        centerTitle: true,
      ),
      body: Container(
        width: double.infinity,
        height: double.infinity,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(12.w),
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Image.asset(
              'assets/images/bg_store_apply_top.png',
              width: double.infinity,
              height: 370.w,
              fit: BoxFit.fill,
            ),
            Image.asset(
              'assets/images/bg_store_apply_center.png',
              width: double.infinity,
              height: 640.w,
              fit: BoxFit.fill,
            ),
            Divider(
              thickness: 25.w,
              height: 25.w,
              color: Config.colorDivider,
            ),
            Container(
              width: double.infinity,
              padding: EdgeInsets.symmetric(vertical: 30.w, horizontal: 35.w),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    '商家入驻类型',
                    style: TextStyle(color: Config.colorText1, fontSize: 30.w),
                  ),
                  Text(
                    '商家入驻分【商城入驻】和【商圈入驻】',
                    style: TextStyle(color: Config.colorText1, height: 1.8, fontSize: 24.w),
                  ),
                  Text(
                    '商城入驻：线上电商入驻，可上传商品至平台售卖',
                    style: TextStyle(color: Config.colorText1, height: 1.8, fontSize: 24.w),
                  ),
                  Text(
                    '商圈入驻：附近实体店入驻，平台会员可前往消费',
                    style: TextStyle(color: Config.colorText1, height: 1.8, fontSize: 24.w),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
      bottomNavigationBar: Container(
        width: double.infinity,
        height: 110.w,
        padding: EdgeInsets.symmetric(vertical: 10.w, horizontal: 30.w),
        child: ElevatedButton(
          clipBehavior: Clip.antiAlias,
          onPressed: () async {
            Routes.router.pop(context);

            if (entity.code == 1 && (entity.data.status == 'not_applied')) {
              Routes.navigateTo(context, Routes.myStoreToJoin);
            } else {
              Routes.navigateTo(context, Routes.myStoreToJoinAudit);
            }
          },
          style: ElevatedButton.styleFrom(shape: const StadiumBorder()),
          child: const Text('进入我的店铺'),
        ),
      ),
    );
  }
}
